﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace SqlPrompt
{
	class QueryHistory
	{
		public static void LogQuery(DbConnectionInfo dbConnectionInfo, string command, int rowsProcessed)
		{
			string historyFileName = dbConnectionInfo.Name + ".qhr";
			string historyFilePath = Path.Combine(Config.WorkingDirectory, historyFileName);

			command = command.Replace("\r", "").Replace("\n", "");

			string entry = 
				DateTime.Now.ToString("yyyy.MM.dd HH:mm") + "|" +
				rowsProcessed + "|" +
				command + 
				Environment.NewLine;

			File.AppendAllText(historyFilePath, entry);
		}
	}
}
